package com.example.simin_manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.simin_manage.entity.PerformanceRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @description:
 * @author: panpan
 * @time: 2025/9/14
 */
@Mapper
public interface RuleMapper extends BaseMapper<PerformanceRule> {
    @Select("SELECT * FROM performance_period WHERE start_date <= #{start} AND end_date >= #{end} LIMIT 1")
    PerformanceRule findCurrentRule(@Param("start") String start, @Param("end") String end);

    @Select("SELECT * FROM performance_rule WHERE cycle_id=#{cycleId} ORDER BY min_orders ASC")
    List<PerformanceRule> findByCycleId(@Param("cycleId") Long cycleId);
}